<template>
	<view class="b_con" :style="bStyle">
		<view class="b_ele" :style="{'border-color':this.bColor}">
			<view v-if="bElement>=10" :style="{'background-color':this.bColor}" class="b_ele_item" style="width:16%;border-radius: 4rpx 0 0 4rpx;"></view>
			<view v-if="bElement>=40" :style="{'background-color':this.bColor}" class="b_ele_item"></view>
			<view v-if="bElement>=70" :style="{'background-color':this.bColor}" class="b_ele_item"></view>
			<view v-if="bElement>=100" :style="{'background-color':this.bColor}" class="b_ele_item" style="border-radius: 0 4rpx 4rpx 0;border-right:0"></view>
			<view class="b_shan" v-if="bShan">
				<image src="./shan.png" style="width:14rpx;height:24rpx;"></image>
			</view>
		</view>
		<view class="b_tou" :style="{'background-color':this.bColor}"></view>
	</view>
</template>

<script>
	export default {
		name:"LiiyBattery",
		data() {
			return {
				bStyle:{width:this.width, height:this.height},
				bColor:'#999999',
				bElement:100,
				bShan:false,
			};
		},
		methods:{
			//修改电量
			setPower(e){
				this.bElement = e
			},
			setColor(color){
				this.bColor = color;
			},
			setShan(shan){
				this.bShan = shan;
			}
		},
		props:{
			width:{
				 type: String,
				 required: false, 
				 default: '58rpx'
			},
			height:{
				 type: String,
				 required: false, 
				 default: '32rpx'
			}
		},
	}
</script>

<style lang="scss" scoped>
	.b_shan{
		position: absolute;
		width: 100%;
		height:100%;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.b_ele_item{
		width: 28%;
		height: 100%;
		border-right: 2rpx solid #ffffff;
		box-sizing: border-box;
	}
	.b_con{
		display: inline-flex;
		align-items: center;
	}
	.b_ele{
		border-radius: 6rpx;
		width:93%;
		height:100%;
		border:3rpx solid;
		box-sizing: border-box;
		padding:1rpx;
		display: flex;
		position: relative;
	}
	.b_tou{
		width: 7%;
		height:16rpx;
		border-radius:0 8rpx 8rpx 0 ;
	}
</style>